import SwiftUI
import SPGlassKit

public struct GlassBreadcrumbExample: GlassExample {
    public static let componentID = "glass-breadcrumb"

    private static let fullPath: [GlassBreadcrumbItem<Int>] = [
        GlassBreadcrumbItem(id: 0, title: "Home", systemImage: "house"),
        GlassBreadcrumbItem(id: 1, title: "Projects"),
        GlassBreadcrumbItem(id: 2, title: "2026"),
        GlassBreadcrumbItem(id: 3, title: "Client workshop — été"),
        GlassBreadcrumbItem(id: 4, title: "Photos"),
        GlassBreadcrumbItem(id: 5, title: "Selected 📷"),
    ]

    @State private var depth = 6

    public init() {}

    private var path: [GlassBreadcrumbItem<Int>] { Array(Self.fullPath.prefix(depth)) }

    public var body: some View {
        VStack(alignment: .leading, spacing: 24) {
            GlassBreadcrumb(path) { id in depth = id + 1 }
            GlassBreadcrumb(path, maxVisibleItems: 2) { id in depth = id + 1 }
            GlassBreadcrumb(Array(Self.fullPath.prefix(1))) { _ in }

            Text("Current: \(path.last?.title ?? "—")")
                .font(.callout)
                .foregroundStyle(.secondary)
            Button("Go deeper") { depth = min(depth + 1, Self.fullPath.count) }
                .disabled(depth == Self.fullPath.count)
        }
        .frame(maxWidth: .infinity, alignment: .leading)
        .padding()
    }
}

#Preview("GlassBreadcrumb") { GlassBreadcrumbExample().glassTheme(.emerald) }
